<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:g="http://www.jboss.org/drools/flow/gpd" xmlns:tns="http://www.jboss.org/drools" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.mvel.org/2.0" id="Definition" name="" targetNamespace="http://www.jboss.org/drools" typeLanguage="http://www.java.com/javaTypes">
    <process id="{{entityLogic.bpmnDiagram.id}}" isClosed="false" isExecutable="true" name="{{entityLogic.bpmnDiagram.name}}" processType="Private" tns:packageName="{{packageName}}.core.{{entityLogic.entity.module}}.domain.{{entityLogic.entity.codeName}}">
        <extensionElements>
            {{#each entityLogic.bpmnDiagram.importParams as |param|}}
            <tns:import name="{{param.name}}" />
            {{/each}}
            {{#each entityLogic.bpmnDiagram.globalParams as |param|}}
            <tns:global identifier="_{{param.identifier}}" type="{{param.escapeType}}" />
            {{/each}}
            {{#each entityLogic.bpmnDiagram.metadataParams as |param|}}
            <tns:metaData express="{{param.express}}" name="_{{param.name}}" type="{{param.escapeType}}"/>
            {{/each}}
        </extensionElements>
    {{!-- 输出逻辑节点 --}}
    {{#each entityLogic.bpmnDiagram.nodes as |node|}}
        {{#if (eq logicNodeType 'BEGIN')}}
    <startEvent id="{{node.codeName}}" isInterrupting="true"/>
        {{else if (eq logicNodeType 'END')}}
    <endEvent id="{{node.codeName}}" name="{{node.name}}">
        {{#if (eq node.returnType 'LOGICPARAM')}}
        <extensionElements>
            <tns:metaData name ="_{{lowerCase node.returnParam.codeName}}"  type = "logicParam"/>
        </extensionElements>
        {{/if}}
    </endEvent>
        {{else if (eq logicNodeType 'DELOGIC')}}
    {{!-- 实体处理逻辑 --}}
    <callActivity activiti:exclusive="true" calledElement="{{node.refProcessId}}" id="{{node.codeName}}" name="{{node.name}}"/>
        {{else}}
    <businessRuleTask activiti:exclusive="true" g:ruleFlowGroup="{{node.globalCodeName}}" id="{{node.codeName}}" implementation="http://www.jboss.org/drools/rule" name="{{node.name}}"/>
        {{/if}}
    {{/each}}
    {{!-- 输出交互链接 --}}
    {{#each entityLogic.bpmnDiagram.links}}
    <sequenceFlow id="{{sourceNodeId}}_{{targetNodeId}}" sourceRef="{{sourceNodeId}}" targetRef="{{targetNodeId}}">
        {{#if hasCondition}}
        <conditionExpression  xsi:type="tFormalExpression" language="http://www.mvel.org/2.0" >
            <![CDATA[
            {{conditionExpression}}
            ]]>
        </conditionExpression>
        {{/if}}
    </sequenceFlow>
    {{/each}}
    </process>
</definitions>